/**
 * Developer : aOmMiez
 * Date : 4/9/13 AD
 * Time : 3:45 PM
 * File : index.js
 */


var Place = function(){};

Place.prototype.init = function(req, res){
    if(req.route.method == 'get') {
        this.Place(req, res);
    }
    else if(req.route.method == 'post') {
        this.Place(req, res);
    }
    else if(req.route.method == 'put') {
        // put method
    }
    else if(req.route.method == 'delete') {
        // delet method
    }
};

Place.prototype.Place = function(req, res){
    var pid = req.body.pid;
    GLOBAL.Mysql.query("SELECT id,createById,name,locationId,categoryId,subCategoryId,likeGroupId FROM Place WHERE id = '"+pid+"' ",function(zErr, zRes){
        if (zErr) {
            throw new Exception(9999, 'Mysql Error: '+zErr, function(){
                console.log('Mysql Error: '+zErr);
                res.send(this.toString());
                res.end();
            });
        } else {
            if (zRes.length == 0 ) {
                throw new Exception(9999, 'this place id not in database ', function(){
                    res.send(this.toString());
                    res.end();
                });
            } else {
                res.send(JSON.stringify(zRes));
                res.end();
            }
        }
    });
};
module.exports = Place;